package cloud.xlh.digital_power_order.controller;

import cloud.xlh.digital_power_order.client.order.dto.GenOrderReqDTO;
import cloud.xlh.digital_power_order.client.order.dto.RefundOrderReqDTO;
import cloud.xlh.digital_power_order.client.order.service.OrderClientService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2023/8/12 18:04
 * @ Description:
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderClientService orderClientService;

    @PostMapping("/genOrder")
    public String genOrder(@RequestBody GenOrderReqDTO genOrderReqDTO) {
        return orderClientService.genOrder(genOrderReqDTO);
    }

    @GetMapping("/selectOrder/{orderNo}")
    public String selectOrder(@PathVariable("orderNo") String orderNo) {
        return orderClientService.selectOrder(orderNo);
    }

    @GetMapping("/payOrder/{orderNo}")
    public String payOrder(@PathVariable("orderNo") String orderNo) {
        return orderClientService.payOrder(orderNo);
    }

    @PostMapping("/refundOrder")
    public String refundOrder(@RequestBody RefundOrderReqDTO refundOrderReqDTO) {
        return orderClientService.refundOrder(refundOrderReqDTO);
    }
}
